package servletDemo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "ServletC", value = "/ServletC")
public class ServletC extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*方式一*/

//        response.setStatus(302);
//        response.setHeader("location","/demo01/servletDemo.ServletD");
        /*方式二*/
        response.sendRedirect("/demo01/servletDemo.ServletD");

        response.setStatus(302);
        response.setHeader("location","/demo01/ServletD");
        /*方式二*/
//        System.out.println("ServletC exec");
//        response.sendRedirect("/demo01/ServletD");

        /* 重定向到外部资源 */
        response.sendRedirect("http://www.baidu.com");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
